﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using SkinSharp;

namespace CsharpTpl.window
{
    public partial class FrmSelectSkin : Form
    {
        public FrmSelectSkin()
        {
            InitializeComponent();
            this.Load += new EventHandler(FrmSelectSkin_Load);
            SkinList.MouseDoubleClick += new MouseEventHandler(SkinList_MouseDoubleClick);
        }

        void FrmSelectSkin_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }

        void SkinList_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            SkinList.SelectedItem.ToString();
            Console.WriteLine(SkinList.SelectedItem.ToString());
            File.Copy(Application.StartupPath + @"/skin/" + SkinList.SelectedItem.ToString(), Application.StartupPath + @"/skinh.she", true);
            FrmLogin.skin.Attach();
        }

        void FrmSelectSkin_Load(object sender, EventArgs e)
        {
            List<string> allfiles = Directory.GetFiles(Application.StartupPath + @"\skin", "*.she").ToList();
            foreach (string file in allfiles)
            {
                SkinList.Items.Add(Path.GetFileName(file));
            }
        }
    }
}
